<template>
  <div>
    <div>
        <el-button @click="exitlogin">退出</el-button>
    </div>
    <el-input v-model="name" placeholder="请输入账号"></el-input>
    <el-input v-model="pwd" placeholder="请输入密码"></el-input>
    <el-button @click="login">登录</el-button>
    
  </div>

</template>

<script>
export default {
  data() {
    return {
      name: "",
      pwd: "",
      tokens:localStorage.getItem('token')
    };
    
  },
  methods: {
    login() {
      // 
      this.axios.post("adminlogin",{name:this.name,pwd:this.pwd}).then((res) => {
        if (res.data.code == 200) {
          localStorage.setItem("uid", res.data.uid);
          localStorage.setItem("token", res.data.token);
          localStorage.setItem("roleid", res.data.roleid);

        window.location.href = "http://localhost:8080/leftrbac";
   

          if (res.data.tip == 0) {
            window.location.href = "http://localhost:8080/#/updateuser";
          }
        }

        alert(res.data.msg);
      });
    },
    exitlogin(){
       

        this.axios.get('exitlogin')
        .then(res=>{
            alert(res.data.msg)
            // localStorage.clear()
			//   //加入该行后会清除缓存，当点击退出按钮后，会清除登录信息缓存
			// window.sessionStorage.clear()
			// this.$router.push('/login')
	   
        })
    }
  },
};
</script>

<style>
</style>